package com.bloody.android.Bluetooth;

import android.content.Intent;
import android.os.Bundle;

import com.bloody.android.R;
import com.bloody.android.Map.Map;
import com.bloody.android.Observer.Observer;

public class Join extends MBT implements Observer {
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.create);
        
        Intent serverIntent = new Intent(this, DeviceListActivity.class);
        startActivityForResult(serverIntent, super.getRequestConnectDeviceSecure());
	}
	
	/*public void infoMap(Bundle _bundle) {
		// TODO Auto-generated method stub
		super.setBundle(_bundle);
    	super.getBundle().putInt("player", 2);
	}*/

	@Override
	public void setCharacters(Bundle _bundle)
	{
		super.setCharacters(_bundle);
    	Bundle bundle = new Bundle();
    	bundle.putBoolean("create", false);
    	
    	//characters sur la map
    	super.characterSelection(bundle);
	}
	
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(requestCode == MBT.CHARACTERS_SELECTED){
        	Bundle info = data.getExtras();
        	super.sendMessage(info);
        	launchBcg();
        }
		else{
			super.onActivityResult(requestCode, resultCode, data);
		}
	}

	@Override
	public void update(Bundle bundle) {
		super.update(bundle);
		if(bundle.getString("type").equalsIgnoreCase("map"))
		{
			Bundle info = new Bundle();
			info.putSerializable("map", new Map(bundle.getStringArray("datas")));
			super.setBundle(info);
	    	super.getBundle().putInt("player", 2);
		}
	}
}
